package com.lintesis.lintesisview.webgui.protocolo.medicamento;

import org.zkoss.zkplus.databind.BindingListModel;
import org.zkoss.zkplus.databind.BindingListModelList;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Decimalbox;
import org.zkoss.zul.Textbox;

import com.lintesis.lintesismodel.common.hibernate.GenericDAO;
import com.lintesis.lintesismodel.protocolo.Composicion;
import com.lintesis.lintesismodel.protocolo.Medicamento;
import com.lintesis.lintesisview.common.ABMDialogCtrl;
import com.lintesis.lintesisview.common.menu.UserWorkspace;

public class MedicamentoDialogCtrl extends ABMDialogCtrl<Medicamento> {

	private static final long serialVersionUID = -4862752641889224718L;
	
	static final String rightPreffix = "medicamento.dialog.";

	Textbox tbNombre;
	Textbox tbLaboratorio;
	Decimalbox tbDosisRecomendada;
	Combobox cbComposicion;
	
	BindingListModel lmComposiciones;
	
	@Override
	protected void doSetClearComponents() {
		clearComponents.add(tbNombre);
		clearComponents.add(tbLaboratorio);
		clearComponents.add(tbDosisRecomendada);
		clearComponents.add(cbComposicion);	
		
	}

	@Override
	protected void doSetFieldProperties() {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void doSetReadOnlyComponents() throws Exception {
		roComponents.addAll(clearComponents);
		
	}

	@Override
	protected void doSetValidation() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void fillBussinesObject() throws Exception {
		// TODO Auto-generated method stub
		
	}

	@Override
	protected void fillComboBoxs() throws Exception {
		try
		{
			lmComposiciones = new BindingListModelList(new GenericDAO<Composicion>(UserWorkspace.getInstance().gethSession()).getByBussinessObject(new Composicion()), true);
		} catch (Exception e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

	@Override
	public String getEntityName() {
		return "Medicamento";
	}

	@Override
	protected Medicamento getNewEntidad() {
		Medicamento medicamento=new Medicamento();
		return medicamento;
	}

	@Override
	protected String getRightPreffix() {
		return rightPreffix;
	}

}
